package com.ktmall.pojo;

import com.mysql.cj.util.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.List;

/**
 * 商品实体类，对应`t_goods_info`商品信息表
 * @version v1.0
 * @Author 郴州科泰
 * @Create 2024-07-19 - 15:42
 */
@Data
@NoArgsConstructor
public class GoodsItem {
    private Integer id;
    private String goodsName;  // 商品名称
    private String spuCode; // 商品SPU，即商品的唯一标识
    private Integer categoryId; // 商品的二级分类id
    private Integer brandId;   // 品牌id
    private String goodsImg;  // 商品图片
    private String goodsDesc;  // 商品描述
    private BigDecimal goodsPrice;  // 商品价格
    private Integer publishStatus;  // 上架状态[0 - 下架，1 - 上架]
    private Integer orderNum;     // 排序值
    private String mainPictures;  // 商品主图的图片地址，多个图片地址使用逗号隔开
    private String [] mainImg;  // 商品主图的图片地址,按逗号拆分成数组.
    private String detailsPictures;  // 商品详情的图片地址，逗号隔开。
    private String [] picturesArr;  // 商品详情的图片地址数组。
    private List<SkuItem> skus;  // 商品的SKU列表
    private List<AttrItem> specs; // 商品的规格属性列表
    private CategoryItem categories;  // 商品分类对象
    private BrandItem brandItem;  // 品牌对象
    private String createTime;  // 创建时间
    private String updateTime;  // 更新时间

    public GoodsItem(Integer id, String goodsName, String spuCode, Integer categoryId, Integer brandId, String goodsImg, String goodsDesc, BigDecimal goodsPrice, Integer publishStatus, Integer orderNum, String mainPictures, String[] mainImg, String detailsPictures, String[] picturesArr, List<SkuItem> skus, List<AttrItem> specs, CategoryItem categories, BrandItem brandItem, String createTime, String updateTime) {
        this.id = id;
        this.goodsName = goodsName;
        this.spuCode = spuCode;
        this.categoryId = categoryId;
        this.brandId = brandId;
        this.goodsImg = goodsImg;
        this.goodsDesc = goodsDesc;
        this.goodsPrice = goodsPrice;
        this.publishStatus = publishStatus;
        this.orderNum = orderNum;
        this.mainPictures = mainPictures;
        if(!StringUtils.isNullOrEmpty(mainPictures)){
            this.mainImg = mainPictures.split(",");
        }
        if(!StringUtils.isNullOrEmpty(detailsPictures)){
            this.picturesArr = detailsPictures.split(",");
        }
        this.detailsPictures = detailsPictures;
        this.skus = skus;
        this.specs = specs;
        this.categories = categories;
        this.brandItem = brandItem;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
}
